<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Ref
 *
 * @author Moon
 */
class marking extends CUniqueValidator{
    //put your code here

    public $dateAttr = '';

    public $required = false;
    
    public function validateAttribute($model,$attribute)
    {
    	if($this->dateAttr == '')
    		$_date = date('Y');
    	else {
    		$dateAttr = $this->dateAttr;
        	$_date = $model->$dateAttr;
        	$date = explode("/", $_date);
        	$_date = $date[2];//date('Y',mktime(0,0,0,$date[1],$date[0],$date[2]));
    	}
        $criteria = new CDbCriteria;
        $criteria->condition = "from_unixtime(".$this->dateAttr.",'%Y')=:year";
        $criteria->params = array(':year'=>$_date);
        $this->criteria = $criteria;
        return parent::validateAttribute($model, $attribute);
    }
}
?>
